//
//  ClockPageView.swift
//  ClockIn
//
//  Created by enrique leo on 10/8/21.
//

import SwiftUI

//let date = "\(Date())"
//    .split(separator: " ")[0]

struct ClockPageView: View {
    @State private var share: String = "此刻发现..."
    @State private var share1: String = ""
    @State private var firstEdit: Bool = true
    @State private var fontColor: UIColor = UIColor.separator
    
    var body: some View {
        ZStack{
            
            Color(UIColor.systemGray6)
            
            VStack{
                HStack{
                    
                    Spacer()
                    
                    VStack(){
                        Spacer()
                        Text("日期")
                            .frame(height: 40)
                        
                        Spacer()
                        Text("地点")
                            .frame(height: 40)
                        Spacer()
                        Text("景点名称")
                            .frame(height: 40)
                        Spacer()
                    }
                    .frame(height: UIScreen.main.bounds.height * 0.3)
                    
                    Spacer()
                    
                    VStack{
                        Spacer()
                        TextField(date, text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/)
                            .padding(.leading, 5)
                            .frame(width: UIScreen.main.bounds.width * 0.65, height: 40)
                            .border(Color(UIColor.separator))
                            .background(Color(UIColor.white))
                        
                        Spacer()
                        TextField("", text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/)
                            .padding(.leading, 5)
                            .frame(width: UIScreen.main.bounds.width * 0.65, height: 40)
                            .border(Color(UIColor.separator))
                            .background(Color(UIColor.white))
                        
                        Spacer()
                        TextField("", text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/)
                            .padding(.leading, 5)
                            .frame(width: UIScreen.main.bounds.width * 0.65, height: 40)
                            .border(Color(UIColor.separator))
                            .background(Color(UIColor.white))
                        
                        Spacer()
                    }
                    .frame(height: UIScreen.main.bounds.height * 0.3)
                    
                    Spacer()
                }
                
                TextEditor(text: $share)    .foregroundColor(Color(fontColor))
                    .onChange(of: share, perform: { value in
                        if firstEdit {
                            share = ""
                            firstEdit = false
                            fontColor = UIColor.black
                        }
                    })
                    .frame(width: UIScreen.main.bounds.width * 0.90, height: 100)
                    .border(Color(UIColor.separator))
                
                
                
                Spacer()
                
            }
        }
    }
}

struct ClockPageView_Previews: PreviewProvider {
    static var previews: some View {
        ClockPageView()
    }
}
